import json
path = 'example.txt'
records = [json.loads(line) for line in open(path)]

# print records[0]
# print records[0]['tz']

time_zones = [rec['tz'] for rec in records if 'tz' in rec]

# print time_zones[:10]

def get_counts(sequence):
    counts = {}
    for x in sequence:
        if x in counts:
            counts[x] +=1
        else:
            counts[x] = 1
    return counts

counts = get_counts(time_zones)

# print counts['America/New_York']
# print len(time_zones)

def top_counts(count_dict, n=10):
    value_key_pairs = [(count, tz) for tz, count in count_dict.items()]
    value_key_pairs.sort()
    return value_key_pairs[-n:]

top_counts = top_counts(counts, 5)

# print top_counts

